function f = loss_Combined(lambda_n)
%input: column vector lambda_(nth iter)
%output: calculated cost value
global testdata trainingdata;
global route_costs indexsubroutine;


H = [trainingdata(:,1:2) ones(length(trainingdata(:,1)),1)];

%Find probabilities q on test data (size 6)
Ftest=testdata(:,1:2)*lambda_n(1:2) + lambda_n(3);   %This is DIFFERENT THAN GLMFIT
q=ones(length(testdata(:,3)),1)./(ones(length(testdata(:,3)),1)+exp(-Ftest));
[val,x] = gurobi_milp(q);
route_costs(indexsubroutine) = val;
indexsubroutine  = indexsubroutine + 1;

f = sum(log(1+(exp(-(trainingdata(:,3).*(H*lambda_n))))')) + val;

